public class Test {
    public static void main(String[] args) {


    }
}
    /*移除链表元素
        class Solution {
    public ListNode removeElements(ListNode head, int val) {
        if(head == null) {
            return null;
        }
        ListNode curPre = head;
        ListNode cur = head.next;
        while(cur != null) {
            if(cur.val == val) {
                curPre.next = cur.next;
                cur = cur.next;
            }
            else {
             cur = cur.next;
             curPre = curPre.next;
            }
        }
        if(head.val == val) {
            head = head.next;
        }
        return head;
    }
}
         */

/*相交链表
public class Solution {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        if(headA == null) {
            return null;
        }
        if(headB == null) {
            return null;
        }
        int count1 = 0;
        int count2 = 0;
        ListNode cur1 = headA;
        ListNode cur2 = headB;
        while(cur1 != null) {
            count1++;
            cur1 = cur1.next;
        }
        while(cur2 != null) {
            count2++;
            cur2 = cur2.next;
        }
        int count = count1 - count2;
        if(count < 0) {
            ListNode tmp = headA;
            headA = headB;
            headB = tmp;
            count = count2 - count1;
        }
        while(count != 0) {
            headA = headA.next;
            count--;
        }
        while(headA != headB ) {
            headA = headA.next;
            headB = headB.next;
        }
        return headA;

    }
}
 */
/*
class Solution {
    public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
        if(list1 == null && list2 == null) {
            return null;
        }
        ListNode sss = new ListNode(-1);

        ListNode ss = sss;
        while(list1 != null && list2 !=null) {
            if(list1.val >= list2.val ) {
                ss.next = list2;
                ss = ss.next;
                list2 = list2.next;
            }
            else {
                ss.next = list1;
                ss = ss.next;
                list1 = list1.next;
            }
        }
        if(list1 !=null) {
            ss.next = list1;
        }
        if(list2 != null) {
            ss.next = list2;
        }
        return sss.next;

    }
}
 */
/*
链表的回文结构
public class PalindromeList {
    public boolean chkPalindrome(ListNode head) {
       ListNode slow = head;
       ListNode fast = head;
       // 找到中间节点
       while(fast != null && fast.next != null) {
        fast = fast.next.next;
        slow = slow.next;
       }
       //反转
       ListNode cur = slow.next;
       while(cur != null) {
        ListNode curNext = cur.next;
        cur.next = slow;
        slow = cur;
        cur = curNext;
       }
       //逼近
       while(head != slow) {
        if(head.val != slow.val){
            return false;
        }
        if(head.next == slow) {
            return true;

        }
        head = head.next;
        slow = slow.next;
       }
       return true;

    }
}
 */
/*
链表分割
public class Partition {
    public ListNode partition(ListNode head, int x) {
        if(head == null) {
            return null;
        }
        ListNode bs = null;
        ListNode be = null;
        ListNode as = null;
        ListNode ae = null;
        while(head != null) {
            if(head.val < x) {
                if(bs == null && be== null) {
                    bs = head;
                    be = head;
                } else {
                    be.next = head;
                    be = be.next;
                }
            } else {
                if(as == null && ae == null) {
                    as = head;
                    ae = head;
                } else {
                    ae.next = head;
                    ae = ae.next;
                }
            }
            head = head.next;
        }

        if(bs == null) {
            return as;
        }

        if(as != null) {
            ae.next = null;
        }
        be.next = as;

        return bs;
    }
}
 */
/*

 */